<extend name="Index/index" />

<block name="link">
    <!-- <link rel="shortcut icon" href="http://steamcommunity.com/favicon.ico" type="image/x-icon"> -->
    <link href="__PUBLIC__/css/home_topic/buttons.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/css/home_topic/globalv2.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/css/home_topic/apphub.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/css/home_topic/apphub_home.css" rel="stylesheet" type="text/css">
    <link href="__PUBLIC__/css/home_topic/forums.css" rel="stylesheet" type="text/css">
        <!-- 样式文件 -->
    <link rel="stylesheet" href="__ROOT__/umeditor/themes/default/css/umeditor.css">
    <!-- 引用jquery -->
    <script src="__PUBLIC__/js/home_index/jquery.min.js"></script>
    <!-- 配置文件 -->
    <script type="text/javascript" src="__ROOT__/umeditor/umeditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__ROOT__/umeditor/umeditor.js"></script>
    <!-- 语言包文件 -->
    <script type="text/javascript" src="__ROOT__/umeditor/lang/zh-cn/zh-cn.js"></script>
    <!-- 实例化编辑器代码 -->
    <script type="text/javascript">
        $(function(){
            window.um = UM.getEditor('container', {
                /* 传入配置参数,可配参数列表看umeditor.config.js */
                toolbar: ['source | undo redo | bold italic underline |  forecolor | selectall cleardoc | emotion image map'
            ]
            });
        });
    </script>
</block>
<block name="main">
    <div class="apphub_HomeHeaderContent">
        <div class="apphub_sectionTabs responsive_hidden">
            <a href="<{:U('Topic/index')}>"  class="apphub_sectionTab active "><span>全部</span></a>
            <a href="<{:U('Topic/index')}>"  class="apphub_sectionTab "><span>讨论</span></a>
            <div style="clear: left"></div>
        </div>
    </div>
    <div id="AppHubContent" class="apphub_Discussion_Content" style="min-height:403px">
        <div class="leftcol">
            <div class="nonresponsive_hidden forum_responsive_newtopic_action">
                <div onclick="Forum_CreateTopic( &#39;General_3703047&#39; ); $J(this).parent().slideUp( 250 );" class="btn_darkblue_white_innerfade btn_medium ">
                    <span>发起新讨论</span>
                </div>
            </div>
            <div class="forum_area" id="forum_General_3703047_area">
                <div id="forum_General_3703047_newtopic_area" style="display: none;">
                    <div class="forum_newtopic_area">
                        <div class="forum_newtopic_header">
                            发起新讨论
                        </div>
                        <div class="forum_newtopic_box">
                            您必须通过<a href="https://steamcommunity.com/login/home/?goto=app%2F570%2Fdiscussions%2F">登录</a>或<a href="http://store.steampowered.com/join/">创建帐户</a>进行操作。
                        </div>
                    </div>
                </div>
                
                <div id="AppHubContent" class="apphub_Content">
                    <div class="leftcol">
                        <div>
                            <div class="forum_breadcrumbs group_content_bodytext">
                                <a href="<{:U('Index/index')}>">Dota 2</a> &gt;
                                <a href="<{:U('Topic/index')}>">综合讨论</a> &gt;
                                <span>主题详情</span>
                            </div>
                        </div>
                        <div class="forum_op" id="forum_op_144512526679939249">
                            <div class="forum_op_avatar playerAvatar in-game">
                                <a href="<{:U('User/detail',array('uid'=>$data['u_id']))}>">
                                    <if condition="$data['icon'] eq '' ">
                                    <img src="__PUBLIC__/images/home_person/default_icon.jpg">
                                    <else />
                                    <img src="<{$iconpath}><{$data.icon}>" width=40 height=40>
                                    </if>
                                </a>
                            </div>
                            <div class="authorline">
                                <a class="hoverunderline forum_op_author">
                                    <if condition="$data.nickname"><{$data.nickname}>
                                    <else /><{$data.email}>
                                    </if>
                                </a>
                                <span class="date"><{$data.time|date="Y-m-d H:i:s",###}>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                
                                <a id="topic_collect" style="color:#ccc;display:none">收藏</a>
                                <a id="topic_collected" style="color:#ccc;display:none">已收藏</a>

                                </span>
                            </div>
                            <div class="topic">
                                <{$data.title}>
                            </div>
                            <div class="content"">
                                <{$data.content}>
                            </div>
                        </div>
                        <!-- 回复 -->
                        <volist name="list" id="vo">
                        <div class="forumtopic_comments">
                            <div class="commentthread_comment responsive_body_text">
                                <div class="commentthread_comment_avatar playerAvatar offline">
                                    <a href="<{:U('User/detail',array('uid'=>$vo['uid']))}>">
                                        <if condition="$vo[icon] eq '' ">
                                        <img src="__PUBLIC__/images/home_person/default_icon.jpg" width=40 height=40>
                                        <else />
                                        <img src="<{$vo.icon}>" width=40 height=40>
                                        </if>
                                    </a>
                                </div>
                                <div class="commentthread_comment_content">
                                    <div class="commentthread_comment_author">
                                        <a class="commentthread_author_link " href="#" >
                                            <bdi><{$vo.nickname}>
                                            </bdi>
                                        </a>
                                        <span class="commentthread_comment_timestamp"><{$vo.time|date="Y-m-d H:i:s",###}></span>　<lzl style="cursor:pointer">回复</lzl>
                                    </div>
                                    <div class="commentthread_comment_text">
                                        <{$vo.content}> <br><br>

                                            <volist name="vo.reply_floor" id="v">
                                            <div class="commentthread_comment responsive_body_text">
                                                <div class="commentthread_comment_avatar playerAvatar offline">
                                                    <a href="<{:U('User/detail',array('uid'=>$v['uid']))}>">
                                                        <if condition="$v[icon] eq '' ">
                                                        <img src="__PUBLIC__/images/home_person/default_icon.jpg" width=40 height=40>
                                                        <else />
                                                        <img src="<{$v.icon}>" width=40 height=40>
                                                        </if>
                                                    </a>
                                                </div>
                                                <div class="commentthread_comment_content">
                                                    <div class="commentthread_comment_author">
                                                        <a class="commentthread_author_link " href="#" >
                                                            <bdi><{$v.nickname}>
                                                            </bdi>
                                                        </a>
                                                        <span class="commentthread_comment_timestamp"><{$v.time|date="Y-m-d H:i:s",###}></span>
                                                    </div>
                                                    <div class="commentthread_comment_text">
                                                        <{$v.content}>
                                                     </div>
                                                </div>
                                            </div>
                                            </volist>
                                            <div style="display:none">
                                                <input type="text" style="padding:10px;width:548px">
                                                <button class="btn-sm">回复</button>
                                            </div>
                                    </div>
                                </div><br>
                                <div class="forum_comment_permlink">
                                    <a href="#">#<span><{$vo.floor}></span></a>
                                </div>
                            </div>
                        </div>
                        </volist>
                    </div>
                </div>
            </div>
        </div>
        <div class="rightcol responsive_local_menu">
            <form class="" method="GET" name="DiscussionSearchForm" action="">
                <div class="discussionSearchTextContainer">
                    <input class="discussionSearchText" type="text" name="q" value="" placeholder="搜索讨论">
                    <img class="discussionSearchTextSubmitImg" src="__PUBLIC__/images/home_topic/searchbox_workshop_submit.gif" width="23" height="18" border="0">
                </div>
            </form>
            <br>
            <div class="rightbox">
                <div class="content">
                    <a class="btn_darkblue_white_innerfade btn_medium " style="background:#333"><span>发表回复</span></a>
                </div>
            </div>
        </div>
        <div style="clear: both;"></div>
        <div id="page">
        <{$page}>
        </div>
        <script>
            $('#page div').attr('class','').css({'margin':'15px 0'}).children('li').css({'float':'left','font-size':'14px','padding':'3px 7px'});
        </script>
    </div>
    <br>
    <br>
    <div style="margin:10px 163px;display:none" id="umeditor" >
        <span class="glyphicon glyphicon-pencil" style=" font-size:14px;font-family: Microsoft Yahei,ST Hei">发表回复</span>
        <script id="container" name="content" type="text/plain" style="width:640px;height:200px;"></script>
        <button class="btn" style="margin-top:5px">发表</button>
    </div>
    <div style="height:50px"></div>
    <script>
        $.ajax({
            url:"<{:U('Topic/check_session')}>",
            success:function(data){
                if (data==1) {
                    $('#umeditor').css('display','block');
                    $.ajax({
                        url:"<{:U('Topic/check_collect',array('uid'=>$_SESSION['uid'],'tid'=>$_GET['t']))}>",
                        success:function(aaa){
                            if (aaa == 1) {
                                $('#topic_collected').css('display','inline-block');
                                $('#topic_collect').css('display','none');
                            }else{
                                $('#topic_collect').css('display','inline-block');
                                $('#topic_collected').css('display','none');
                            }
                        }
                    })
                }
            }
        })
        
        $('a:contains("发表回复")').click(function(){
            $.ajax({
                url:"<{:U('Topic/check_session')}>",
                success:function(data){
                    if (data) {
                        $('body').scrollTop(100000);
                        $('#container').focus();
                    }else{
                        alert('请先登录');
                        window.location.href = "<{:U('Login/index')}>";
                    }
                }
            })
        })

        $('button:contains("发表")').click(function(){
            var content = um.getContent();
            $.ajax({
                type:'post',
                url:"<{:U('Topic/reply',['tid'=>$_GET['t']])}>",
                data:{'content':content},
                success:function(data){
                    if (data==1) {alert('发表失败');}
                    window.location.reload();
                }
            })
        })

        var mark = 1;
        $('lzl').click(function(){
            if (mark==1) {
                $(this).parent().parent().children().eq(1).children('div:hidden').css('display','block').children('input').focus();
                mark = 0;
            }else{
                $(this).parent().parent().children().eq(1).children('div:last-child').css('display','none');
                mark = 1;
            }
            
        })

        $('button:contains("回复")').click(function(){
            var content = $(this).prev().val();
            var floor = $(this).parent().parent().parent().next().next().children().children().html();
            $.ajax({
                type:'post',
                url:"<{:U('Topic/reply_floor',['tid'=>$_GET['t']])}>",
                data:{'content':content,'floor':floor},
                success:function(data){
                    alert(data)
                    if (data==1) {alert('回复失败');}
                    window.location.reload();
                }
            })
        })

        $('#topic_collect').click(function(){
            $.ajax({
                url:"<{:U('Topic/topic_collect',array('uid'=>$_SESSION['uid'],'tid'=>$_GET['t']))}>",
                success:function(data){
                    if (data) {
                        alert('收藏成功');
                        $('#topic_collect').css('display','none');
                        $('#topic_collected').css('display','inline-block');
                    }else{
                        alert('收藏失败');
                    }
                }
            })
        })

        $('#topic_collected').click(function(){
            $.ajax({
                url:"<{:U('Topic/topic_uncollect',array('uid'=>$_SESSION['uid'],'tid'=>$_GET['t']))}>",
                success:function(data){
                    if (data == 1) {
                        alert('取消成功');
                        $('#topic_collect').css('display','inline-block');
                        $('#topic_collected').css('display','none');
                    }else{
                        alert('取消失败');
                    }
                }
            })
        })

    </script>
</block>
